#ifndef SESSION_MANAGER_H
#define SESSION_MANAGER_H

#include <mutex>
#include <unordered_map>

#include "common/elements/user.h"
#include "common/more/uuid.h"

class Session;

class SessionManager final
{
public:
    ~SessionManager();

    void killExpiredSessions();

    Elements::UserPtr userBySession(const Uuids::Uuid& uuid);

    Uuids::Uuid createSession(Elements::UserPtr user);
    bool removeSession(const Uuids::Uuid& uuid);

private:
    std::recursive_mutex m_locker;
    std::unordered_map<Uuids::Uuid, std::shared_ptr<Session>> m_sessions;
};

#endif // SESSION_MANAGER_H
